﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using LocalDBLayer.Data;

namespace You2VTool.Controls
{
	/// <summary>
	/// Interaction logic for Report.xaml
	/// </summary>
	public partial class Report : UserControl
	{
		public Report()
		{
			InitializeComponent();
			InitReports();
		}

		private void InitReports()
		{
			You2VReportCollection p_collection = new You2VReportCollection();
			cb_Reports.ItemsSource = p_collection.Items;
			cb_Reports.DisplayMemberPath = "name";
			cb_Reports.SelectedIndex = -1;  //未选中
		}

		private void BindingDataTable()
		{
			You2VReport report = (You2VReport)cb_Reports.SelectedItem;

            if (report != null)
            {
                dg_report.ItemsSource = report.GetReport().DefaultView;
            }
		}

		private void cb_Reports_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			BindingDataTable();
		}

        private void RefreshButton_Click(object sender, RoutedEventArgs e)
        {
            BindingDataTable();
        }
	}
}
